<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=k, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <span>你的所在地区为:<h1></h1><h2></h2></span>
    <span>你的网络运用商是:<h3></h3></span>
    <div id="city"></div>
</body>
<script>
    // 1.第一步创建对象
    let xhr = new XMLHttpRequest()
    // 2.第二步建立连接
    xhr.open("get","https://tenapi.cn/v2/getip",true)   
    // 3.第三步发送请求
    xhr.send(null)
    // 4.第四步接收数据
    xhr.onreadystatechange =function(){
         if(xhr.readyState == 4 && xhr.status == 200){
            console.log(JSON.parse(xhr.responseText))
            document.querySelector("h1").innerText = JSON.parse(xhr.responseText).data.country
            document.querySelector("h2").innerText = JSON.parse(xhr.responseText).data.province
            document.querySelector("h3").innerText = JSON.parse(xhr.responseText).data.isp
            document.querySelector("city").innerText = JSON.parse(xhr.responseText).data.city
        }
    }
</script>
</html>